package com.example.newbee.mvp.view;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

import com.example.mylibrary.mvp.view.BaseActivity;
import com.example.newbee.R;
import com.example.newbee.mvp.contact.RegisterContact;
import com.example.newbee.mvp.model.RegisterModel;
import com.example.newbee.mvp.presenter.RegisterPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RegisterActivity extends BaseActivity<RegisterPresenter> implements RegisterContact.View {
    RegisterPresenter registerPresenter;
    @BindView(R.id.userId)
    EditText userId;
    @BindView(R.id.pwdId)
    EditText pwdId;
    @BindView(R.id.registerId)
    Button registerId;

    @Override
    public int bondLayout() {
        return R.layout.activity_register;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        registerPresenter=new RegisterPresenter(new RegisterModel(),this);
    }

    @Override
    public void loadLayout() {

    }

    @Override
    public void hideLayout() {

    }

    @Override
    public String getUsername() {
        return userId.getText().toString().trim();
    }


    @Override
    public String getPwd() {
        return pwdId.getText().toString().trim();
    }

    @Override
    public void goLogin() {
        Intent intent = new Intent(this,LoginActivity.class);
        intent.putExtra("user",userId.getText().toString().trim());
        intent.putExtra("pwd",pwdId.getText().toString().trim());
        startActivity(intent);
    }

    @Override
    public void goMain() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.registerId)
    public void onViewClicked() {
        registerPresenter.register();
    }

}
